-
-
Notifications
You must be signed in to change notification settings - Fork 144
feat(series): arithmetic sub #1312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
1bcf162
to
c9c46b0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #1311 you added support for bool
in addition, so don't you want to include the bool
tests for subtraction as well?
It's really nice that the pattern on these operators is similar so it seems pretty straightforward to get them working.
tests/series/test_series.py
Outdated
@@ -819,7 +819,7 @@ def test_types_element_wise_arithmetic() -> None: | |||
check(assert_type(s.add(s2, fill_value=0), "pd.Series[int]"), pd.Series, np.integer) | |||
|
|||
# TODO this one below should type pd.Series[int] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove this comment now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pd.Series([True]) - pd.Series([True]) # TypeError: numpy boolean subtract, the `-` operator, is not supported, use the bitwise_xor, the `^` operator, or the logical_xor function instead. |
But they can be subtracted from non-bools: pd.Series([3,4,5])-pd.Series([True, False, True])
0 2
1 4
2 4
dtype: int64 So I would think you would want to add those to the tests. |
|
||
def test_sub_py_scalar() -> None: | ||
"""Test pd.Series[complex] - Python native scalars""" | ||
i, f, c = 1, 1.0, 1j |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could do:
i, f, c = 1, 1.0, 1j | |
b, i, f, c = True, 1, 1.0, 1j |
And then add the tests on b
here, and similar in the other funcs.
This is inspired by #1274 and a follow-up for #1275.
assert_type()
to assert the type of any return value(I thought cmp0xff#1 would automatically redirect to pandas-dev/pandas-stubs, which did not happen)